package com.itheima.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.ydd.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 * @since 2022-02-22
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {
    @Select("SELECT menu_id FROM sys_role_menu WHERE role_id=#{id}")
    Integer[] getMenuIds(String id);

    @Insert("<script>"
            + "INSERT INTO sys_role_menu (role_id,menu_id) VALUES " +
            "<foreach collection='menuids'  item='menuid' separator=','> " +
            "(#{id},#{menuid})" +
            "</foreach>;"
            + "</script>")
    void addmenuid(Integer[] menuids, String id);

    @Delete("DELETE FROM sys_role_menu WHERE role_id=#{id}")
    void deleteMenid(String id);


}
